﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace Nirvana
{

    [CustomPropertyDrawer(typeof(ModelImportConfig))]
    public sealed class ModelImportConfigPropertyDrawer : PropertyDrawer
    {
        private int index = 0;

        public override void OnGUI(Rect pos, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, property);

           // EditorGUI.PrefixLabel(pos, GUIUtility.GetControlID(FocusType.Passive), label);
            EditorGUI.indentLevel++;

            SerializedProperty scaleFactor = property.FindPropertyRelative("scaleFactor");
            SerializedProperty isReadable = property.FindPropertyRelative("isReadable");
            SerializedProperty optimizeMesh = property.FindPropertyRelative("optimizeMesh");
            SerializedProperty meshCompression = property.FindPropertyRelative("meshCompression");
            SerializedProperty weldVertices = property.FindPropertyRelative("weldVertices");
            SerializedProperty importBlendShapes = property.FindPropertyRelative("importBlendShapes");
            SerializedProperty importVisibility = property.FindPropertyRelative("importVisibility");
            SerializedProperty importCameras = property.FindPropertyRelative("importCameras");
            SerializedProperty importLights = property.FindPropertyRelative("importLights");
            SerializedProperty preserveHierarchy = property.FindPropertyRelative("preserveHierarchy");
            SerializedProperty generateColliders = property.FindPropertyRelative("generateColliders");
            SerializedProperty keepQuads = property.FindPropertyRelative("keepQuads");
            SerializedProperty swapUVChannels = property.FindPropertyRelative("swapUVChannels");
    

            index = 0;
            DrawInfo(pos);
            DrawMeshCompressGUI(pos,meshCompression);
            DrawMeshReadWriteGUI(pos, isReadable);
            DrawMeshOptimizeGUI(pos, optimizeMesh);
            DrawMeshWeldVerticesGUI(pos, weldVertices);
            DrawMeshGenerateCollidersGUI(pos, generateColliders);
            DrawMeshNormalsTangentsGUI(pos, property);
            DrawMeshClearUVandColorGUI(pos, property);
#if !UNITY_2019_1_OR_NEWER
            DrawMeshClearDefaultMaterialGUI(pos, property);
#endif
            int offsetY = 5;
            index = index + 3;
            var r1 = new Rect(pos.x, pos.y + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight*2);
            index++;
            var r2 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 2;
            var r3 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 2;
            var r4 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 2;
            var r5 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r6 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r7 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
           
            var r8 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r9 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r10 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r11 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r12 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r13 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r14 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            offsetY = offsetY + 5;
            var r15 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;
            var r16 = new Rect(pos.x, pos.y + offsetY + index++ * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            offsetY = offsetY + 5;


            EditorGUI.LabelField(r1, new GUIContent("为了补偿unity和其它三维建模软件间的单位差异，没有特殊需求的话设为1就可以了"));
            EditorGUI.PropertyField(r2, scaleFactor);
            EditorGUI.LabelField(r3, new GUIContent("导入BlendShapes，启用此属性可允许Unity导入网格物体的混合形状"));
            EditorGUI.PropertyField(r4, importBlendShapes);
            EditorGUI.LabelField(r5, new GUIContent("可见性，动画曲线可以通过控制 Renderer.enabled 属性来启用或禁用 MeshRenderer 组件"));
            EditorGUI.PropertyField(r6, importVisibility);

            EditorGUI.LabelField(r7, new GUIContent("从FBX文件导入摄像机，建议关闭"));
            EditorGUI.PropertyField(r8, importCameras);

            EditorGUI.LabelField(r9, new GUIContent("从FBX文件导入光源，建议关闭"));
            EditorGUI.PropertyField(r10, importLights);

            EditorGUI.LabelField(r11, new GUIContent("当有多个fbx文件，每个文件可能只需要部分骨骼节点，如果不勾选，可能会导致骨骼对不上，默认关闭"));
            EditorGUI.PropertyField(r12, preserveHierarchy);
            EditorGUI.LabelField(r13, new GUIContent("保持四边形，不转换为三角形,默认关闭"));
            EditorGUI.PropertyField(r14, keepQuads);

            EditorGUI.LabelField(r15, new GUIContent("在网格中交换 UV 通道。如果漫射纹理使用光照贴图中的 UV，请使用此选项"));
            EditorGUI.PropertyField(r16, swapUVChannels);

            
            EditorGUI.indentLevel--;

            EditorGUI.EndProperty();

        }

        /// <summary>
        /// 绘制所有属性字段在GUI上所需的整体长度
        /// </summary>
        /// <param name="property"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return 110 * EditorGUIUtility.singleLineHeight;
        }

        private void DrawInfo(Rect pos)
        {
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 7 * EditorGUIUtility.singleLineHeight);
            index = index + 7;
            var r3 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r4= new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 6 * EditorGUIUtility.singleLineHeight);
            index = index + 6;

            EditorGUI.LabelField(r1, "Vertex Compression", GUITheme.LabelTitleStyle);            
            EditorGUI.HelpBox(r2,
                "开启在 PlayerSetting窗口OtherSetting选项卡下:\n\n" +
                "Vertex Compression通过对顶点的数据存储格式进行压缩，达到节约运行时的内存使用目的。\n\n" +
                "在Unity中，Mesh每个顶点都包含Position、Color、Normal、Tangent以及纹理坐标TexCoord等多个通道的数据。\n\n" +
                "VertexCompression的实现是将顶点指定通道的数据格式format设置为16bit，因此可以节约运行时的内存使用（float->half)。\n\n" +
                "当开启PlaySetting >Dynamic Batching选项时，Unity只会对顶点数超过300的Mesh执行Vertex Compression\n", MessageType.None);

            EditorGUI.LabelField(r3, "Optimize Mesh Data", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r4,
                "开启在 PlayerSetting窗口OtherSetting选项卡下:\n\n" +
                "Optimize Mesh Data的工作原理是剔除没有使用的顶点通道数据，也可以起到节约运行时内存使用的作用。\n\n" +
                "但是，这个选项需要谨慎使用，开启这个选项后，Unity会自动丢弃一些Mesh数据，\n\n" +
                "这可能会导致运行时的Mesh数据与输入的Mesh数据不同，造成潜在的问题。\n", MessageType.None);

        }
    
        private void DrawMeshCompressGUI(Rect pos,SerializedProperty animationType)
        {
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y  + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y +5+ (++index) * EditorGUIUtility.singleLineHeight, pos.width, 6*EditorGUIUtility.singleLineHeight);
            index = index + 6;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, pos.y + (++index) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Mesh Compression", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "Mesh Compression选项可以选择三种不同的压缩等级，它实现原理是通过压缩算法将Mesh数据压缩，从而达到节省硬盘空间的目的。\n\n" +
            "但是，在运行时Mesh数据会解压缩为原精度的数据。也就是说，Mesh Compression 只能节省硬盘的存储空间，并不能节约运行时的内存使用。\n\n" +
            "而且开启MeshCompression选项有可能会导致Mesh变形，因此使用此选项不应使Mesh产生太大的变形。此外，开启Mesh Compression会使PlayerSetting下的Vertex Compression和Optimize Mesh Data失效。\n\n" +
            "建议关闭，不开启，优化内存\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, animationType);
            GUI.color = Color.white;
        }

        private void DrawMeshReadWriteGUI(Rect pos, SerializedProperty animationType)
        {
            index++;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 4 * EditorGUIUtility.singleLineHeight);
            index = index + 4;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, pos.y + (++index) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Read/Write Enabled", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "unity会把mesh数据传给GPU，如果开启Read/Write，CPU也会保存一份Mesh数据，\n\n" +
            "Read/Write Enabled这个选项也会使Vertex Compression失效。所以一般情况下，为了节约内存最好不好勾选这个选项，除了无法进行顶点压缩之外，它还会额外在内存中保留一份mesh数据。\n\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, animationType);
            GUI.color = Color.white;
        }
        private void DrawMeshOptimizeGUI(Rect pos, SerializedProperty animationType)
        {
            index++;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 2 * EditorGUIUtility.singleLineHeight);
            index = index + 2;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, pos.y + (++index) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Optimize Mesh", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "Optimize Mesh的作用原理是对Mesh的三角形排列进行优化，重新排序顶点和顶点索引，从而提升GPU的表现。因此，Optimize Mesh 可以优化运行时Mesh的渲染性能。\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, animationType);
            GUI.color = Color.white;
        }

        private void DrawMeshWeldVerticesGUI(Rect pos, SerializedProperty animationType)
        {
            index++;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 2 * EditorGUIUtility.singleLineHeight);
            index = index + 2;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, pos.y + (++index) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Weld Vertices", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "Weld Vertices选项的工作原理是合并处于同一位置的顶点，从而达到减少Mesh顶点数的目的。因此，Weld Vertices 选项可以节约运行时内存使用，优化运行时Mesh渲染性能。\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, animationType);
            GUI.color = Color.white;
        }

        private void DrawMeshGenerateCollidersGUI(Rect pos, SerializedProperty animationType)
        {
            index++;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 3 * EditorGUIUtility.singleLineHeight);
            index = index + 3;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, pos.y + (++index) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Generate Colliders", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "Mesh导入时会自动生成MeshCollider，建筑类静态物体可以开启，动作形变的物体如人物模型不适合开启\n\n" +
            "一般静态物体也别开启，让美术优化做个减面减顶点的相似网格，以此网格生成Collider，这样能大量减少碰撞体的顶点数，优化性能。", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, animationType);
            GUI.color = Color.white;
        }

        private void DrawMeshNormalsTangentsGUI(Rect pos, SerializedProperty property)
        {

            SerializedProperty importNormals = property.FindPropertyRelative("normals");
            SerializedProperty normalSmoothingAngle = property.FindPropertyRelative("normalSmoothingAngle");
            SerializedProperty importTangents = property.FindPropertyRelative("tangents");

            index++;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 4 * EditorGUIUtility.singleLineHeight);
            index = index + 7;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, r2.y + (5) * EditorGUIUtility.singleLineHeight-5, pos.width, EditorGUIUtility.singleLineHeight);
            var r5= new Rect(pos.x, r2.y + (6) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r6 = new Rect(pos.x, r2.y + (7) * EditorGUIUtility.singleLineHeight+5, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "Normals & Tangents", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "导入模型时，可以选择直接导入模型中的法线和切线、也可以选择使用unity自动计算法线和切线、也可以不导入法线和切线.\n\n" +
            "如果美术资源提供了法线和切线、直接import就行了。\n\n" +
            "Smoothing Angle: 控制是否为硬边拆分顶点。通常，值越大，产生的顶点越少。仅当 Normals 设置为 Calculate 时才可用。\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, importNormals);
            EditorGUI.PropertyField(r5, normalSmoothingAngle);
            EditorGUI.PropertyField(r6, importTangents);

            GUI.color = Color.white;
        }

        private void DrawMeshClearUVandColorGUI(Rect pos, SerializedProperty property)
        {

            SerializedProperty uv2 = property.FindPropertyRelative("uv2");
            SerializedProperty uv3_4 = property.FindPropertyRelative("uv3_4");
            SerializedProperty color = property.FindPropertyRelative("color");
            SerializedProperty tangentChannel = property.FindPropertyRelative("tangentChannel");


            index = index+2;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 3 * EditorGUIUtility.singleLineHeight);
            index = index + 7;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);

            var r4 = new Rect(pos.x, r2.y + (4) * EditorGUIUtility.singleLineHeight - 5, pos.width, EditorGUIUtility.singleLineHeight);
            var r5 = new Rect(pos.x, r2.y + (5) * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r6 = new Rect(pos.x, r2.y + (6) * EditorGUIUtility.singleLineHeight + 5, pos.width, EditorGUIUtility.singleLineHeight);
            var r7 = new Rect(pos.x, r2.y + (7) * EditorGUIUtility.singleLineHeight + 5, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "清除无用 UV2,UV3,UV4,Color通道", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
            "清除无用通道，优化模型占用的内存\n\n" +
            "UV2一般用于Unity的光照贴图占用，如果不烘焙的话，可以清除。\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, uv2,new GUIContent("Clear UV2"));
            EditorGUI.PropertyField(r5, uv3_4, new GUIContent("Clear UV3 UV4"));
            EditorGUI.PropertyField(r6, color, new GUIContent("Clear Color"));
            EditorGUI.PropertyField(r7, tangentChannel, new GUIContent("Clear Tangents"));

            GUI.color = Color.white;
        }
        
        private void DrawMeshClearDefaultMaterialGUI(Rect pos, SerializedProperty property)
        {
            SerializedProperty isClear = property.FindPropertyRelative("clearDefaultMaterial");
            SerializedProperty isReplace = property.FindPropertyRelative("replaceDefaultMaterial");

            index = index + 2;
            int startIndex = index;
            var r1 = new Rect(pos.x, pos.y + ++index * EditorGUIUtility.singleLineHeight, pos.width, EditorGUIUtility.singleLineHeight);
            var r2 = new Rect(pos.x, pos.y + 5 + (++index) * EditorGUIUtility.singleLineHeight, pos.width, 4 * EditorGUIUtility.singleLineHeight);
            index = index + 5;
            int board = 4;
            var wrap = new Rect(r2.x - board, r2.y - board, pos.width + 2 * board, (index - startIndex) * EditorGUIUtility.singleLineHeight + 2 * board);
            var r4 = new Rect(pos.x, r2.y + (5) * EditorGUIUtility.singleLineHeight - 5, pos.width, EditorGUIUtility.singleLineHeight);
            var r5 = new Rect(pos.x, r2.y + (6) * EditorGUIUtility.singleLineHeight - 5, pos.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.DrawRect(wrap, new Color(0.25f, 0.25f, 0.25f, 1));
            EditorGUI.LabelField(r1, "清除或替换FBX上的Default-Material", GUITheme.LabelTitleStyle);
            EditorGUI.HelpBox(r2,
                "Unity2019版本以上已经解决了FBX的Prefab加载时，生成的Default-Material材质球造成的Standard.Parse性能消耗和StandardLab占用内存过高问题。因此，无需去清除FBX的Renderer上的材质球。\n" +
                "\n清除：直接对FBX材质置Null，FBX成紫色." +
                "\n替换：会创建本地Resource/BuildInShader/Default_Mat.mat材质球替换默认的FBX材质球,替换时，把Import Material关闭不开启，避免FBX自带材质球\n", MessageType.None);
            GUI.color = Color.yellow;
            EditorGUI.PropertyField(r4, isClear, new GUIContent("Clear Default-Material"));
            EditorGUI.PropertyField(r5, isReplace, new GUIContent("Replace Default-Material"));
            
            GUI.color = Color.white;

        }

    }
}

